package com.canbot.u05.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import com.canbot.u05.R;
import com.canbot.u05.bean.Brow;

import java.util.List;

/**
 * 舞蹈适配器
 */

public class DanceAdapter extends BaseAdapter {

        List<Brow> mbrowList;

        LayoutInflater inflater;

        Context mContext;


        public DanceAdapter(Context mContext, List<Brow> mbrowList) {
                this.mbrowList = mbrowList;
                this.mContext = mContext;
                inflater = LayoutInflater.from(mContext);
        }

        @Override
        public int getCount() {
                return mbrowList.size();
        }

        @Override
        public Object getItem(int i) {
                return mbrowList.get(i);
        }

        @Override
        public long getItemId(int i) {
                return i;
        }

        @Override
        public View getView(int i, View convertView, ViewGroup viewGroup) {
                ViewHolder holder;
                if (convertView == null) {
                        holder = new ViewHolder();
                        convertView = LayoutInflater.from(mContext).inflate(R.layout.dance_item, null);
                        holder.speechName = (Button) convertView.findViewById(R.id.dance_icon_item_btn);
                        holder.speechName.setText(mbrowList.get(i).getName());
                        convertView.setTag(holder);
                }
                else {
                        holder = (ViewHolder) convertView.getTag();
                        holder.speechName.setText(mbrowList.get(i).getName());
                }

                return convertView;
        }

        protected class ViewHolder {

                public Button speechName;

        }

}
